package cn.gok.shiro.Test;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;
import sun.security.provider.MD5;

/**
 * @Author: LKSV
 * @Description:
 * @Date:Created in 17:44 2021/8/17
 */
public class Test02 {
    public static void main(String[] args) {
        String password = "123";//明码
        Object source = password;//要加密的密码

        Object salt = "Q4F%";//盐值，一般都是用户名或者userid，要保证唯一
        int hashIterations = 1024;//加密次数

        SimpleHash simpleHash = new SimpleHash("MD5",source,salt,hashIterations);
        System.out.println("加盐加次数="+simpleHash);//打印出经过盐值、加密次数、md5后的密码

        SimpleHash simpleHash1 = new SimpleHash("MD5",source,salt);
        System.out.println("只加盐="+simpleHash1);
        SimpleHash simpleHash11 = new SimpleHash("MD5",source,"");
        System.out.println("加空盐="+simpleHash11);
        SimpleHash simpleHash12 = new SimpleHash("MD5",source);
        System.out.println("不加盐="+simpleHash12);

        SimpleHash simpleHash2 = new SimpleHash("MD5",source,"",hashIterations);
        System.out.println("只加次数="+simpleHash2);


        Object source2 = "a36a923925a387636772b6430c01e82f";
        SimpleHash simpleHash3 = new SimpleHash("MD5",source2,"",hashIterations);
        System.out.println("加完盐后加次数="+simpleHash3);

        Object source3 = "64c8b1e43d8ba3115ab40bcea57f010b";
        SimpleHash simpleHash4 = new SimpleHash("MD5",source3,salt);
        System.out.println("加完次数后加盐="+simpleHash4);
    }
}
